
import {getAllProducte} from '@/api/products'

// 状态
const state ={
    all: []
}
// 修改state状态
const mutations = {
    setAll(state, products) {
        state.all = products
    }
}

const getters = {
    count: state => state.count
}
// 异步action动作
// 调用 mutations
const actions = {
    init({commit}) {
        // 调用ajax
       getAllProducte().then((res) => {
        
        commit("setAll", res.data.data)
       })
    }
}

export default {
    namespaced: true,
    state: state,
    getters,
    actions,
    mutations
}